import pygame
from pygame.locals import *
import pygame.sprite

print "unidades.robots.robots_ataque cargado satisfactoriamente"

class RobotGolpeador(pygame.sprite.Sprite):
    def __init__(self, linea):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.image.load("robotGolpeCamina1.png").convert_alpha()
        self.rect = self.image.get_rect()
        self.linea = linea
        self.linea.cantidad_atacantes+=1
        self.rect.centerx = 1060
        self.rect.centery = self.linea.y
        self.vida = 50
        self.ataque = 5
        self.frames = 0
        self.atacando = False
        self.mask = pygame.mask.from_surface(self.image)
    def update(self):
        self.frames += 1
        if self.atacando == False:
            if self.frames % 99 < 33:
                self.image = pygame.image.load("robotGolpeCamina1.png").convert_alpha()
            elif self.frames % 99 < 66:
                self.image = pygame.image.load("robotGolpeCamina2.png").convert_alpha()
            else:
                self.image = pygame.image.load("robotGolpeCamina3.png").convert_alpha()
        else:
            if self.frames % 99 < 33:
                self.image = pygame.image.load("robotGolpePega1.png").convert_alpha()
            elif self.frames % 99 < 66:
                self.image = pygame.image.load("robotGolpePega2.png").convert_alpha()
            elif self.frames % 99 < 66:
                self.image = pygame.image.load("robotGolpeador3.png").convert_alpha()
            else:
                self.image = pygame.image.load("robotGolpeador3.png").convert_alpha()
        self.verifica_vida()
        self.avanza()
    def verifica_vida(self):
        if self.vida <= 0:
            self.linea.cantidad_atacantes-=1
            self.kill()
    def avanza(self):
        if self.rect.left <0:
            self.kill()
        else:
            self.rect.move_ip(-1,0)
    def recibir_ataque(self, value):
        self.vida -= value